<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>商家搜索</title>
    <meta name="description" content="安装通优质集采供应商库，是由多家优质的供应商组成，为采购商提供优质的产品资源，让采购商不再为找产品而烦恼。">
    <meta name="keywords" content="集采供应商,优质供应商">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link href="/res/css/respective/xiangMuHui/xiangMuHui.css" rel="stylesheet">
    <link href="/res/css/mall/mallIndex.css" rel="stylesheet">
    <link href="/res/third/city-picker/css/city-picker.css" rel="stylesheet">
    <style>
    h5.major{
    	width: 95%;
    	overflow: hidden;
    	word-break:break-all;
    	white-space: nowrap;
    	text-overflow:ellipsis;
    }
    .spCent.itermOne .city-select>a{
    	float: left;
    }
    .city-picker-span{
    	display: inline-block;
    	border-bottom: none;
    }
    .city-picker-span > .arrow{
    	right: 0px;
    }
    .laypage_main{
    	text-align: center;
    	padding: 20px 0px;
    }
    .city-select.province dd{
    	overflow: hidden;
    }
    .city-select a{
    	float: left;
    }
    .city-select dd{
    	overflow: hidden;
    }
    .city-select-tab{
    	text-align: left;
    }
    </style>
</head>
<body style="background-color: #f5f5f5;">
	[#include "/front/common/front_headMal.html"]
	<div class="w1200">
	    <h6 class="bread" style="display: inline-block;margin-right: 15px;">当前位置：首页 &gt; 供应商</h6>
	</div>
	<div class="xiangMuHuiOuter suply">
		<div style="background: #f5f5f5;">
	        <div class="spCent itermOne" style="background-color: white;">
	            <div class="addIterm" style="margin-bottom: 0px;" id="searchItem">
	                <strong>供应商</strong>
	                <dfn>共找到 <strong  id="total" style="color: #00ceff;margin-right: 4px;">0</strong>条符合条件的查询结果</dfn>
	            </div> 
	            <hr style="margin: 0px;"> 
	            <div class="spCent itermTwo">
		            <table style="width: 1200px;">
		                <caption class="boxShadow" style="border-bottom: 1px solid #dedede;background-color: white;">
		                    <div style="display: inline-block;float: left;position: relative;">
		                        <b class="acTab" style="border-top: none;border-left: none;border-right: none;"  >综合排序</b>
                                <input id="areaProvince" value="" placeholder="全部地区" style="font-size: medium;border: none;">
		                    </div>
		                    <div class="fanYe" style="font-size: 14px;">
		                        <em style="color: #fca711;" id="pageNo">0</em>
		                        <em style="margin-left: 0px;" id="pages" >/0</em>
		                        <a id="prevPage" href="javascript:void(0);" >&lt;</a>
		                        <a id="nextPage" style="margin-left: -4px;" href="javascript:void(0);">&gt;</a>
		                    </div>
		                </caption> 
		            </table> 
		        </div>
	        </div>
	        <div id="boxShadow">

            </div>

            <div id="laypage" ></div>
	    </div>
	</div>
	[#include "/front/common/front_foot.html"]
<script id="template"  type="text/html">
	{{each list as allext  }}
    <div class="boxShadow" style="overflow: hidden; width: 1200px; margin: 0px auto;background-color: white;margin-top: 15px;">
        <div class="store fll" style="width: 500px;">
            <div style="border-right: 1px solid #ebebeb;margin-top: 25px;">
                <div class="detail" style="padding-top: 0px;">
                    <h4 style="font-size: 18px;margin-bottom: 15px;">
                       <a  class="companyName" style="color:#666;" href="/shop/{{allext.shop.id}}" target="_blank">{{allext.companyName}}</a>
                    </h4>
                    <h5>
                        <small>联系人：</small> {{allext.shop.cantactName}}  {{if allext.shop.qq && allext.shop.qq!='' }}<a class="connMe" href="tencent://message/?uin={{allext.shop.qq}}&amp;Site=www.azt365.com&amp;Menu=yes"><img alt="" src="/res/images/oparaStatus/ask.gif"></a>{{/if}}
                    </h5>
                    <h5>
                        {{if allext.shop.cantactTel && allext.shop.cantactTel!='' }}<small>手机号：</small><span >{{allext.shop.telSecret}}</span>{{/if}}
                    </h5>

                    <h5>
                        <small>所在地区：</small> {{allext.shop.provinceName}} {{allext.shop.cityName}}
                    </h5>
                    <h5 class="major">
                        <small>主营类目：</small>
                        {{each allext.categories  cat index }}
                            {{if index != 0 }}
                                |
                            {{/if}}
                            {{ cat.categoryName }}
                        {{/each}}
                    </h5>
                    <h5 style="margin-top: 10px;">
                        <img style="vertical-align: middle;" src="/res/images/respective/mall/sure_03.jpg" alt="" />
                        <small style="vertical-align: middle;">以上信息已通过安装通深度认证</small>
                    </h5>
                </div>
            </div>
        </div>
        <div class="store flr" style="width: 665px;">
            <div class="iterm2 search" style="min-height: auto;margin-top: 10px;">
                <ul>
                    {{each allext.products as product xx }}
                    <li  {{if (xx+1)%4==0 }} style="margin-right: 0px;" {{/if}} >
                        <a href="/offer/{{product.id}}.html" target="_blank">
                            <p>
                                <img   src="/res/images/defat.png"   original="{{product.firstImg}}">
                            </p>
                        </a>
                        <a href="/offer/{{product.id}}.html" target="_blank" class="godName">{{product.name }}</a>
                        <h3>{{ product.minMemberPrice  | priceFormat}}</h3>
                    </li>
                    {{/each}}
                </ul>
            </div>
        </div>
    </div>

    {{/each}}
</script>
    <script src="/res/third/layer/layer.js"></script>
    <script src="/res/third/laypage/laypage.min.js"></script>
    <script src="/res/third/laytpl/laytpl.js"></script>
    <script src="/res/third/laytpl/template.js"></script>
    <script src="/res/third/layer/layer.extends.js"></script>
    <script src="/res/third/city-picker/js/city-picker.data.js"></script>
    <script src="/res/third/city-picker/js/city-picker.js"></script>
    <script src="/res/js/common/common.js"></script>
    <script src="/res/js/common/lazyload.js"></script>
<script type="text/javascript">

    var searchParam={keywords:'${(param.keywords)!}',pageNo:${param.pageNo!1},provinceCode:"${(param.provinceCode)!''}",cityCode:"${(param.cityCode)!''}" };

	var provider = {
        _tempId:"template",
        _containerId:"products",
        _totalPage:0,
        offerSearch:function (rebuidpage,storestat) {//检索
            var _this =this;
            var data = searchParam;
            $('#keywords').val($.trim(searchParam.keywords));//头部搜索框
			$("#searchtype").val(2);
            changeSearchType($("#searchtype"));//选中供应商列

            layer.post({
                url:"/provider/provider_search",
                data:JSON.stringify(data),
                contentType:"application/json",
                success:function (result) {

                    //头部分页
                    $("#pageNo").text(result.totalCount==0?1:result.pageNo);
                    $("#pages").text("/ "+result.totalPage);
                    _this._totalPage=result.totalPage;

                    $("#total").text(result.totalCount)
                    //产品
                    var html = template("template",{list:result.list,total:result.totalCount});
                    $('#boxShadow').html(html);
                    initImageLoad();

                    if(rebuidpage){
                        //底部分页
                        _this.layerPage(result.totalPage,_this);
                    }

                    if(!storestat){
                        //地区选择
                        _this.initCityPicker();
                    }


                    //保存状态
                    _this.pushUrl(storestat);

                    $(".godName.product").each(function(){
                        $(this).ellipsis({maxWidth:180,maxLine:2});
                    });

                    $(".store.fll ul.hot.proType li>span a").each(function(){
                        $(this).ellipsis({maxWidth:180,maxLine:2});
                    });

                    $(".store.flr .iterm2 ul.proType li a.godName.product").each(function(){
                        $(this).ellipsis({maxWidth:150,maxLine:2});
                    });

                    _this.replaceToRed();
                }
            });
        },
        pushUrl:function(storestat,path){//path:url参数 ,storestat ,是否保存状态

            var href = path || location.href.split("?")[0];
            var params=[];
            if(searchParam.provinceCode!=""){
                params.push("provinceCode="+searchParam.provinceCode);
            }
            if(searchParam.cityCode!=""){
                params.push("cityCode="+searchParam.cityCode);
            }
            if(searchParam.keywords!=""){
                params.push("keywords="+searchParam.keywords);
            }

            if(searchParam.pageNo!=1){
                params.push("pageNo="+searchParam.pageNo);
            }

            var paramStr="";
            if(params.length!=0){
                href=href+"?"+params.join("&");
            }
            if ('pushState' in history && storestat ) {
                history.pushState(searchParam,document.title,href);
            }
            return href;
        },
        replaceToRed:function () {
            var keyword = $.trim(searchParam.keywords);
            if(keyword!=""){
                $(".companyName").each(function () {
                    var text = $(this).text();
                    var html = text.replace(new RegExp($.trim(keyword),'gi'),"<span style='color: red;font-weight: bold' >"+keyword+"</span>");
                    $(this).html(html);
                });
            }
        },
        templateHelper:function(){//模板价格格式化
            template.config("escape", false);
            template.helper('priceFormat', function (price, format) {
                return $.my.currency(price,true);
            });
        },
        layerPage:function (totalPage,_this){//分页
            laypage({
                cont: 'laypage',
                pages: totalPage,
                first:1,
                last: totalPage,
                curr:searchParam.pageNo,
                skin: 'molv',
                jump: function(obj, first) {
                    if(!first){ //点击跳页触发函数自身，并传递当前页：obj.curr
//                        location.href="#topsell";
                        window.scrollTo(0,200);
                        searchParam.pageNo=obj.curr;
                        _this.offerSearch(false,true);
                    }
                }
            });
        },
        initCityPicker:function(){//选择地区
            var provinceCode = searchParam.provinceCode;
            var cityCode = searchParam.cityCode;
            var values=[];
            if(provinceCode!=""){
                values.push(ChineseDistricts["no"+provinceCode]);
            }
            if(cityCode!=""){
                values.push(ChineseDistricts[provinceCode][cityCode]);
            }

            $("#areaProvince").val(values.join("/"));

            var hasinit = $("#areaProvince").data("citypicker");
            if(hasinit){
                hasinit.refresh(true,true);
            }
            //地区
            $("#areaProvince").citypicker({canremove:true,level:"city",simple:true,feedValBack:function (v,byhand) {
                var data = $("#areaProvince").data("citypicker");
                if(data){
                    var getcode = $.trim(data.getCode());
                    if(getcode==""){
                        searchParam.provinceCode="";
                        searchParam.cityCode="";
                    }else{
                        if(getcode.indexOf("/")!=-1){
                            var codes = getcode.split("/");
                            searchParam.provinceCode=codes[0];
                            searchParam.cityCode=codes[1];
                        }else{
                            searchParam.provinceCode=getcode;
                        }
                    }
                    searchParam.pageNo=1;
                    if(!byhand){//不是手动调的citypicker的refresh    hasinit.refresh(true,true); ,则要存stat
                        provider.offerSearch(true,true);
                    }
                }
            }});
        },
		init:function (fn) {
            _this = this;
            if (typeof fn === "function"){
                fn();
            }

            if ('pushState' in history) {
                window.addEventListener("popstate", function (e) {
                    if(history.state){
                        searchParam = history.state;
                        provider.offerSearch(true,false);
                    }
                });
            }

            this.templateHelper();
            this.offerSearch(true,true);
            this.initCityPicker();
            return this;
      }
	}.init(function(){
        //上一页
        $("#prevPage").click(function(){
            searchParam.pageNo=searchParam.pageNo>1?searchParam.pageNo-1:1;
            provider.offerSearch(true,true);
        });

        //下一页
        $("#nextPage").click(function(){
            searchParam.pageNo=searchParam.pageNo < provider._totalPage?searchParam.pageNo+1:provider._totalPage;
            provider.offerSearch(true,true);
        })
    });




</script>
</body>
</html>
